package cn.tedu.store.service.impl;


import cn.tedu.store.entity.Employee;
import cn.tedu.store.entity.LisWorkgroup;
import cn.tedu.store.mapper.*;
import cn.tedu.store.service.PeopleGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PeopleGroupServiceImpl implements PeopleGroupService {
    @Autowired
    PeopleGroupMapper peopleGroupMapper;
    @Autowired
    FuYouGroupMapper fuYouGroupMapper;
    @Autowired
    JiKongGroupMapper jiKongGroupMapper;
    @Autowired
    ZhongYiGroupMapper zhongYiGroupMapper;

    @Override
    public LisWorkgroup getSign(String personId, String personName) {
        if (peopleGroupMapper.exist(personId,personName)>=1){
        LisWorkgroup sign = peopleGroupMapper.selectSign(personId,personName);
        return sign;}else if (fuYouGroupMapper.exist(personId,personName)>=1){
            LisWorkgroup sign = fuYouGroupMapper.selectSign(personId,personName);
            return sign;
        }else if (jiKongGroupMapper.exist(personId,personName)>=1){
           LisWorkgroup sign  = jiKongGroupMapper.selectSign(personId,personName);
        return sign;
        }else if (zhongYiGroupMapper.exist(personId,personName)>=1){
            LisWorkgroup sign  = zhongYiGroupMapper.selectSign(personId,personName);
            return sign;
        }
        LisWorkgroup lisWorkgroup = new LisWorkgroup();
        lisWorkgroup.setPersonId("1");
        lisWorkgroup.setCaPersonName(null);
        return lisWorkgroup;
    }
    @Override
    public LisWorkgroup getAudit(String adjustSampleTesterId, String adjustSampleTesterName) {
        if (peopleGroupMapper.existAudit(adjustSampleTesterId, adjustSampleTesterName)>=1) {
            return peopleGroupMapper.selectAudit(adjustSampleTesterId, adjustSampleTesterName);
        } else if (fuYouGroupMapper.existAudit(adjustSampleTesterId, adjustSampleTesterName)>=1) {
            return fuYouGroupMapper.selectAudit(adjustSampleTesterId, adjustSampleTesterName);
        } else if (jiKongGroupMapper.existAudit(adjustSampleTesterId, adjustSampleTesterName)>=1) {
            return jiKongGroupMapper.selectAudit(adjustSampleTesterId, adjustSampleTesterName);
        } else if (zhongYiGroupMapper.existAudit(adjustSampleTesterId, adjustSampleTesterName)>=1) {
            return zhongYiGroupMapper.selectAudit(adjustSampleTesterId, adjustSampleTesterName);
        }
        LisWorkgroup lisWorkgroup = new LisWorkgroup();
        lisWorkgroup.setPersonId("1");
        lisWorkgroup.setCaPersonName(null);
        return lisWorkgroup;
    }

    @Autowired
    EmployeeMapper employeeMapper;
    @Override
    public List<Employee> getCadres() {

        return employeeMapper.findCadres();
    }

    @Override
    public int getCadresOr(String emplCode) {

        return employeeMapper.getInt(emplCode);
    }
}
